<?php
	// If Process type is PREVIEW/EDIT/DELETE, Get All variables needed to be displayed by form, Edit SQL & Variable if necessary !!!
	if($process_type == "PREVIEW" || $process_type == "EDIT" || $process_type == "DELETE")
	{
		$sql2 = "	select a.*, b.productbrandlabel, c.filename
					from tbl_product_class a 
						left join tbl_product_brand b
							on a.productbrandid = b.productbrandid and b.stsrc = 'A'
						left join ms_file c
							on a.productclassurlimage = c.fileid and c.stsrc = 'A'
					where a.stsrc = 'A' and a.productclassid = '".$PK_id."' ";
		$exe2 = mysql_query($sql2) or die(mysql_error());
		$num2 = mysql_num_rows($exe2);
		$row2 = mysql_fetch_array($exe2);
		
		// Set Value if data is found
		if($num2>0)
		{
			$val_productclass_PK_id = $row2['productclassid'];
			$val_productbrand_id = $row2['productbrandid'];
			$val_productbrand_label = $row2['productbrandlabel'];
			$val_productclass_name = $row2['productclassname'];
			$val_productclass_label = $row2['productclasslabel'];
			$val_productclass_content = sql_quote_html_sc_de($row2['productclassdescription']);
			$val_productclass_url_img = $row2['productclassurlimage'];
			$val_productclass_sts_img = $row2['productclassimagestatus'];
			$val_productclass_position = $row2['productclassposition'];
			$val_productclass_activate = $row2['productclassstatus'];
		}
		else
		{
			$val_productclass_PK_id = "";
			$val_productbrand_id = "";
			$val_productbrand_label = "";
			$val_productclass_name = "";
			$val_productclass_label = "";
			$val_productclass_content = "";
			$val_productclass_url_img = "";
			$val_productclass_sts_img = "";
			$val_productclass_position = "";
			$val_productclass_activate = "";
		}
	}
	else
	{
		$val_productclass_PK_id = "";
		$val_productbrand_id = "";
		$val_productbrand_label = "";
		$val_productclass_name = "";
		$val_productclass_label = "";
		$val_productclass_content = "";
		$val_productclass_url_img = "";
		$val_productclass_sts_img = "";
		$val_productclass_position = "";
		$val_productclass_activate = "";
	}
?>
<!-- Start Row Data -->
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Brand</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<?php
			$sql3 = "select productbrandid, productbrandlabel, productbrandname from tbl_product_brand where stsrc = 'A' order by productbrandposition asc ";
			$exe3 = mysql_query($sql3) or die(mysql_error());
			$num3 = mysql_num_rows($exe3);
			
			if($num3 > 0)
			{
		?>
		<select <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> name="txt_productbrand_id">
			<?php if($process_type == "ADD"){ ?><option value="-1" >Select Brand !</option><?php } ?>
			<?php
				while($row3 = mysql_fetch_array($exe3))
				{
			?>
			<option <?php if($row3['productbrandid'] == $val_productbrand_id){echo "selected=selected";} ?> value="<?php echo $row3['productbrandid']; ?>" ><?php echo ucwords(strtolower($row3['productbrandlabel'])); ?></option>
			<?php
				}
			?>
		</select>
		<?php
			}
			else
			{
		?>
			<span style="color:#FF0000;">No Data !</span>
		<?php
			}
		?>
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Name</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input type="hidden" type="productclass" name="txt_productclass_name" value="<?php echo $val_productclass_name; ?>" />
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="productclass" required name="txt_productclass_name" value="<?php echo $val_productclass_name; ?>" style="width:300px; height:18px;" />
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Label</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="productclass" required name="txt_productclass_label" value="<?php echo $val_productclass_label; ?>" style="width:300px; height:18px;" />
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Description</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<textarea class="ckeditor" class="ckeditor" <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> name="txt_productclass_content" style="width:300px; height:100px; max-width:300px; max-height:100px;"><?php echo textarea_string($val_productclass_content); ?></textarea>
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Image</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<?php
			$sql3 = "	select a.fileid, a.filelabel, a.filename, b.imagewidth, b.imageheight
						from ms_file a
							left join ms_image b
								on a.fileid = b.fileid
						where a.filerole = 'image' and a.stsrc = 'A' order by a.filelabel asc ";
			$exe3 = mysql_query($sql3) or die(mysql_error());
			$num3 = mysql_num_rows($exe3);
			
			if($num3 > 0)
			{
		?>
		<select <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> name="txt_productclass_img_url">
			<option value="-1" >Select Image !</option>
			<?php
				while($row3 = mysql_fetch_array($exe3))
				{
			?>
			<option <?php if($row3['fileid'] == $val_productclass_url_img){echo "selected=selected";} ?> value="<?php echo $row3['fileid']; ?>" ><?php echo ucwords(strtolower($row3['filelabel'])); if($row3['imagewidth'] && $row3['imageheight']){ echo " - ".$row3['imagewidth']."x".$row3['imageheight'];} ?></option>
			<?php
				}
			?>
		</select>
		<?php
			}
			else
			{
		?>
			<span style="color:#FF0000;">No Data !</span>
		<?php
			}
		?>
	</div>
	<div style="clear:both;"></div>
</div>
<?php 
	if($row2['filename'] != "" || !empty($row2['filename']))
	{
?>
<div class="divFormRowData">
	<div style="float:left; text-align:left; width:<?php echo $rowDivWidth; ?>px;">Preview</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<?php echo "<img src='".getURLdomain()."/upload/".file_string($row2['filename'])."' style='max-width:800px; max-height:200px;' />"; ?>
	</div>
	<div style="clear:both;"></div>
</div>
<?php
	}
?>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Position</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="number" required min="1" max="100" name="txt_productclass_position" value="<?php echo $val_productclass_position; ?>" style="width:50px; height:18px; font-size:10px;" />
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Show Image</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="radio" name="rdo_productclass_img_sts" value="1" <?php if(isset($val_productclass_sts_img)){if($val_productclass_sts_img == 1){echo "checked='true'";}} ?> /> Yes
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="radio" name="rdo_productclass_img_sts" value="0" <?php if(isset($val_productclass_sts_img)){if($val_productclass_sts_img == 0){echo "checked='true'";}} ?> /> No
	</div>
	<div style="clear:both;"></div>
</div>
<div class="divFormRowData">
	<div style="float:left; text-align:right; width:<?php echo $rowDivWidth; ?>px;">Activate</div>
	<div style="float:left;">&nbsp;:&nbsp;</div>
	<div style="float:left;">
		<input type="hidden" name="txt_productclass_brand" value="<?php echo $val_productclass_brand; ?>" style="width:200px; height:18px;" />
		<input type="hidden" name="txt_productclass_PK_id" value="<?php echo $val_productclass_PK_id; ?>" style="width:200px; height:18px;" />
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="radio" name="rdo_productclass_activate" value="1" <?php if(isset($val_productclass_activate)){if($val_productclass_activate == 1){echo "checked='true'";}} ?> /> Yes
		<input <?php if($process_type == "PREVIEW" || $process_type == "DELETE"){echo "disabled='disabled'";} ?> type="radio" name="rdo_productclass_activate" value="0" <?php if(isset($val_productclass_activate)){if($val_productclass_activate == 0){echo "checked='true'";}} ?> /> No
	</div>
	<div style="clear:both;"></div>
</div>
<!-- End Row Data -->